import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wego.bean.PageBean;
import com.wego.domain.entity.${Entity};
import com.wego.domain.query.${Entity}Query;
import com.wego.mapper.${Entity}Mapper;
import com.wego.service.${Entity}Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ${Entity}ServiceImpl implements ${Entity}Service {
@Autowired
private ${Entity}Mapper ${obj}Mapper;

@Override
public PageBean<${Entity}> getPage(${Entity}Query ${obj}Query) {
    final Integer pageNum = ${obj}Query.getPageNum();
    final Integer pageSize = ${obj}Query.getPageSize();
    final Page<${Entity}> page = PageHelper.startPage(pageNum, pageSize);
        ${obj}Mapper.selectWithCondition(${obj}Query);
        return PageBean.page2pageBean(page);
    }

    @Override
    public ${Entity} getById(Integer id) {
        return ${obj}Mapper.selectByPrimaryKey(id);
    }

    @Override
    public int insertOrUpdate(${Entity} ${obj}) {
        return ${obj}Mapper.insertOrUpdateSelective(${obj});
    }

    @Override
    public int deleteById(Integer id) {
        return ${obj}Mapper.deleteByPrimaryKey(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteByIds(String ids) {
        final String[] split = ids.split(",");
        return ${obj}Mapper.deleteByPrimaryKeyIn(split);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, rollbackFor = Exception.class)
    public int batchInsert(List<${Entity}> ${obj}List) {
        return ${obj}Mapper.batchInsert(${obj}List);
    }
}
